# -*- coding: utf-8 -*-
# @Time    : 2023/10/10 21:12
# @Author  : yan.wei
# @Email   : 13675196684@163.com
# @File    : main.py
# @Software: PyCharm

# 本次实验中，数据量较低，为了呈现好的效果，将满足条件的数据提取出来，复制多遍，加入到源数据

import pandas as pd
df1 = pd.read_csv('OriginalData/fact_epsfb_bigxdr_20220614.csv')
df2 = pd.read_csv('OriginalData/fact_epsfb_bigxdr_20220615.csv')
df3 = pd.read_csv('OriginalData/fact_epsfb_bigxdr_20220616.csv')
df4 = pd.read_csv('OriginalData/fact_epsfb_bigxdr_20220617.csv')
df5 = pd.read_csv('OriginalData/fact_epsfb_bigxdr_20220618.csv')
df6 = pd.read_csv('OriginalData/fact_epsfb_bigxdr_20220619.csv')
df7 = pd.read_csv('OriginalData/fact_epsfb_bigxdr_20220620.csv')

datacomb1 = df1[(df1['epsfb_type'] == 1) & (df1['epsfb_mode'] == 1) & (df1['n2_handoverout_procedurestatus'] == 2)]
datacomb2 = df2[(df2['epsfb_type'] == 1) & (df2['epsfb_mode'] == 1) & (df2['n2_handoverout_procedurestatus'] == 2)]
datacomb3 = df3[(df3['epsfb_type'] == 1) & (df3['epsfb_mode'] == 1) & (df3['n2_handoverout_procedurestatus'] == 2)]
datacomb4 = df4[(df4['epsfb_type'] == 1) & (df4['epsfb_mode'] == 1) & (df4['n2_handoverout_procedurestatus'] == 2)]
datacomb5 = df5[(df5['epsfb_type'] == 1) & (df5['epsfb_mode'] == 1) & (df5['n2_handoverout_procedurestatus'] == 2)]
datacomb6 = df6[(df6['epsfb_type'] == 1) & (df6['epsfb_mode'] == 1) & (df6['n2_handoverout_procedurestatus'] == 2)]
datacomb7 = df7[(df7['epsfb_type'] == 1) & (df7['epsfb_mode'] == 1) & (df7['n2_handoverout_procedurestatus'] == 2)]

tmp = [datacomb1, datacomb2, datacomb3, datacomb4, datacomb5, datacomb6, datacomb7] * 100

dfcomb = pd.concat(tmp)

print(len(dfcomb))

df1 = pd.concat([df1,dfcomb])

date_mapping = {
'2022-06-15': '2022-06-14',
'2022-06-16': '2022-06-14',
'2022-06-17': '2022-06-14',
'2022-06-18': '2022-06-14',
'2022-06-19': '2022-06-14',
'2022-06-20': '2022-06-14'
}

df1 = df1.replace(date_mapping, regex=True)

df1 = df1.sample(frac=1, random_state=42)

df1.to_csv(r'fact_epsfb_bigxdr_20220614-20220620.csv',index=False)